home *** CD-ROM | disk | FTP | other *** search
/ Freelog 125 / Freelog_MarsAvril2015_No125.iso / Musique / Quod Libet / quodlibet-3.3.0-installer.exe / bin / quodlibet / ext / events / radioadmute.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2014-12-31  |  2KB  |  60 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.7)
  3.  
  4. import re
  5. from quodlibet import app
  6. from quodlibet.util import re_escape
  7. from quodlibet.plugins.events import EventPlugin
  8.  
  9. class RadioAdMute(EventPlugin):
  10.     PLUGIN_ID = 'radio_ad_mute'
  11.     PLUGIN_NAME = _('Mute radio ads')
  12.     PLUGIN_VERSION = '0.1'
  13.     PLUGIN_DESC = _('Mute while radio advertisements are playing.\nStations: di.fm')
  14.     SPAM = [
  15.         'www.webex.co.uk',
  16.         'di.fm/premium',
  17.         "There's more to Digitally Imported!",
  18.         'Digitally Imported AMTAG_60 ADWTAG_30000_START=0',
  19.         'Digitally Imported TSTAG_60 ADWTAG',
  20.         'PhotonVPS.com',
  21.         'Get Digitally Imported Premium',
  22.         'More of the show after these messages',
  23.         'Choose premium for the best audio experience',
  24.         'www.di.fm/jobs']
  25.     RE_SPAM = [
  26.         'Sponsored Message\\s+\\([0-9]+\\)']
  27.     SPAM = map(re_escape, SPAM) + RE_SPAM
  28.     SPAM = [ re.compile(s, re.I) for s in SPAM ]
  29.     __old_volume = 0
  30.     __muted = False
  31.     
  32.     def disabled(self):
  33.         self.plugin_on_song_ended()
  34.  
  35.     
  36.     def plugin_on_song_started(self, song):
  37.         if not song or not (song.streamsong):
  38.             return None
  39.         player = None.player
  40.         data = song('~title~artist')
  41.         for spam in self.SPAM:
  42.             if spam.search(data):
  43.                 self._RadioAdMute__old_volume = player.volume
  44.                 self._RadioAdMute__muted = True
  45.                 player.volume = 0
  46.                 break
  47.                 continue
  48.  
  49.     
  50.     def plugin_on_song_ended(self, *args):
  51.         if not self._RadioAdMute__muted:
  52.             return None
  53.         self._RadioAdMute__muted = None
  54.         player = app.player
  55.         if player.volume != 0:
  56.             return None
  57.         player.volume = None._RadioAdMute__old_volume
  58.  
  59.  
  60.